<template>
	<view>
		<view class="pay-back">
			<view>支付金额</view>
			<view class="price-text"><text>¥</text>{{payInfo.pay_price}}</view>
		</view>
		<view class="type-back">
			<view class="title">请选择支付方式</view>
			<view class="pay-item" v-for="(item,index) in payInfo.payList" @click="selectPay(index)">
				<view>{{item.name}}</view>
				<image v-if="index == payIndex" src="../../static/selected.png"></image>
				<image v-else src="../../static/noselect.png"></image>
			</view>
		</view>
		<view class="bottomBt">
			<view class="button" @click="submitPay">确认支付</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "wts-orderPay",
		props: {
			payInfo: '',
		},
		data() {
			return {
				payIndex: 0,
			}
		},
		watch: {

		},
		methods: {
			// 选择支付方式
			selectPay(index) {
				this.payIndex = index
			},
			// 提交支付
			submitPay() {
				this.$emit('submitPay', this.payIndex)
			}
		}
	}
</script>

<style lang="scss">
	.pay-back {
		background-color: #fff;
		text-align: center;
		padding: 40rpx 0;

		.price-text {
			font-size: 50rpx;
			font-weight: bold;
			color: #a20000;
			margin-top: 20rpx;

			text {
				font-size: 34rpx;
				margin-right: 5rpx;
			}
		}
	}

	.type-back {
		margin-top: 20rpx;
		background-color: #fff;

		.title {
			font-weight: bold;
			padding: 30rpx 0 0 30rpx;
		}

		.pay-item {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 30rpx;
			border-bottom: #eee 2rpx solid;

			&:last-of-type {
				border-bottom: none;
			}

			image {
				width: 46rpx;
				height: 46rpx;
			}
		}
	}

	.bottomBt {
		width: 100%;
		padding: 20rpx;
		box-sizing: border-box;
		background: #fff;
		position: fixed;
		left: 0;
		bottom: 0;
		border-top: 1px solid #eee;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
		z-index: 999;

		.button {
			background-color: #a20000;
			color: #fff;
			height: 88rpx;
			border-radius: 44rpx;
			line-height: 88rpx;
			text-align: center;
		}
	}
</style>